package pop3Server;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class DeleteMail {
	
	private static PrintWriter pw=null;
	private BufferedReader br = null;
	
	public DeleteMail(){
		
	}

	public boolean deleMail(String deleName,String toName){
		boolean flag=false;
		File file=new File(deleName);
		try {
			br=new BufferedReader(new InputStreamReader(new FileInputStream(deleName)));
			pw=new PrintWriter(new OutputStreamWriter(new FileOutputStream(toName)));
			String str=null;
			while((str=br.readLine())!=null){
				pw.println(str);
				pw.flush();
			}
			pw.close();
			br.close();
			file.delete();
			flag=true;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return flag;
	}
}
